﻿namespace HuwmanCode.Reflection

open System
open HuwmanCode

[<AutoOpen>]
module MemberInfoExtension =
    type System.Reflection.MemberInfo with
        /// <summary>
        /// Returns an array containing all the custom attributes.
        /// </summary>
        member this.GetCustomAttributes<'attrib> (inherited) =
            this.GetCustomAttributes (typeof<'attrib>, inherited) |> Array.map (fun a -> a :?> 'attrib)

        /// <summary>
        /// Returns the first custom attribute of the type 'attrib
        /// </summary>
        member this.GetCustomAttribute<'attrib> (inherited) =
            this.GetCustomAttributes<'attrib> (inherited) |> Array.nthOrNone 0